<?php
	include_once('header.php');
	include_once('menu.php');
	include_once('content.php');
?>
	<h3>Štatistiky služobných ciest</h3>
<?php
	echo form_open('statistics', array('class'=>'jNice'));
	$nastavenia = array(
		'1' => 'Služobné cesty',
		'2' => 'Muži a ženy',
		'3' => 'Mestá',
		'4' => 'Organizácie',
		'5' => 'Štáty'
	);
	echo form_dropdown('stat', $nastavenia);
	echo form_submit('ukaz', 'Ukáž');
	echo form_close();
?>
<?php  
    echo '<div style="clear: both; margin-top: 100px"><center>';
    if (isset($grafy)) {
    	
        foreach ($grafy as $key => $graf) {
            //echo "<img src='" . rtrim($this->config->item('base_url'), '/') . '/' .  "pictures/" . $graf['image_name'] . "' alt=''/><br/><br/>";
                $graph_data = array();
                if (count($graf['hodnoty'])) { foreach ($graf['hodnoty'] as $name => $count) {
                    if ($count > 0) {
                        $graph_data[] = array($name, $count);
                    }
                }}
            ?>
        
            <div id="graph_<?php echo $key; ?>" style="width: 800px; height: 600px; margin: 20px auto;"></div>

            <script type="text/javascript">
$(function () {
    $('#graph_<?php echo $key; ?>').highcharts({
        chart: {
            type: 'pie',
            options3d: {
				enabled: true,
                alpha: 45,
                beta: 0
            }
        },
        title: {
            text: '<?php echo addslashes($graf['graph_title']); ?>'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.y}</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: false,
                cursor: 'pointer',
                depth: 35,
                dataLabels: {
                    enabled: true,
                    format: '{point.name} ({point.y})'
                },
                showInLegend: true
            }
        },
        series: [{
            type: 'pie',
            name: 'Počet',
            data: <?php echo json_encode($graph_data); ?>
        }]
    });
});
            </script>
            
            <?php
        }
        	
    }
    else {
        echo "<p>Štatistika nie je dostupná.</p>";
    }
    echo "</center></div>";

?>

<?php
	include_once('footer.php');
?>